const but = document.querySelector(".but")
const username = document.querySelector(".username")
const password = document.querySelector(".password")
console.log(username, password);
but.addEventListener("click", async function () {
    var nameIpt = username.value
    var pwdIpt = password.value
    console.log(nameIpt, pwdIpt);
    if (!nameIpt || !pwdIpt) return alert("请完整输入")
    const res = await pAjax({
        url: "../html/login.php",
        method: "post",
        data: `username=${nameIpt}&password=${pwdIpt}`,
        dataType: "json"
    })
    if(res.code===0){
        alert("登陆失败")
        return
    }
    window.localStorage.setItem("id",nameIpt)
    const url = window.localStorage.getItem("url")
    window.location.href=`./${url ? url :'index'}.html`
})